package com.plian.system.service.pf.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.pf.AuditAssets;
import com.plian.system.mapper.pf.AuditAssetsMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.pf.IAuditAssetsService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: Take-off
 * @Description: TODO
 * @Date: 2023/1/3 9:04 PM
 * @Version: 1.0
 **/
@Slf4j
@Service
@AllArgsConstructor
public class AuditAssetsServiceImpl extends BaseServiceImpl<AuditAssetsMapper, AuditAssets> implements IAuditAssetsService {

    @Override
    public boolean deleteByParentId(List<Long> ids) {
        LambdaQueryWrapper<AuditAssets> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(AuditAssets::getBaseBusinessAuditId, ids);
        List<AuditAssets> auditAssets = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(auditAssets)){
            return deleteLogic(auditAssets.stream().map(AuditAssets::getId).collect(Collectors.toList()));
        }
        return true;
    }
}
